# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
# Note: This project is dead, but it's needed for some packages.
pkgname=ruby-hpricot
_gemname=hpricot
pkgver=0.8.6
pkgrel=4
pkgdesc="A swift, liberal HTML parser with a fantastic library (legacy)"
url="https://github.com/hpricot/hpricot"
arch="all"
license="MIT"
checkdepends="ruby-test-unit"
makedepends="ruby-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/hpricot/$_gemname/archive/$pkgver.tar.gz
	rakefile.patch"
builddir="$srcdir/$_gemname-$pkgver"

build() {
	cd "$builddir"

	gem build $_gemname.gemspec
	gem install --local \
		--install-dir dist \
		--ignore-dependencies \
		--no-document \
		--verbose \
		$_gemname
}

check() {
	cd "$builddir"

	local file; for file in test/test_*.rb; do
		ruby -I dist/gems/$_gemname-$pkgver/lib -I test $file
	done
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"
	cd "$builddir"/dist

	mkdir -p "$gemdir"
	cp -r extensions gems specifications "$gemdir"/

	# Remove unnecessary files and rubbish...
	find "$gemdir"/extensions/ -name mkmf.log -delete
	cd "$gemdir"/gems/$_gemname-$pkgver
	rm -r ext/ lib/*.so test/ CHANGELOG* COPYING README* Rakefile
}

sha512sums="0b35295745d36483fbd0c0ea7751c9e9672efdc3738145991a4799e3e2f75ec05cc833b28eacb45631a805b760b6f83a179bbbd830a3b30ea25749d243f527d7  ruby-hpricot-0.8.6.tar.gz
3e6c479302af5964a036ca2c9a9616f3e65f5c0dc60aaf11d3ea5eae2016babd0fd88dfbc6c914a56fd85a2641f6d9ec1b75099bebe0599da530f35e81f26df0  rakefile.patch"
